﻿using System;

using enyo;

namespace com.RexToy
{
    public class WghtView : ConverterView
    {
        private new object[] components = new object[]{ 
            new {kind= ControlKind.BasicScroller, 
                components=new object[] {
                    new {kind=ControlKind.RowGroup, 
                        components= new object[]{
				            new {name= "kg", richContent= false, kind = ControlKind.Input, onblur="blur",
                                    components=new object[]{
					                    new {className= "hint", content= enyo.Global._L("Kg")}
                                    }
                            },
                            new {name= "g", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components= new object[]{
					                    new {className= "hint", content= enyo.Global._L("Gram")}
				                    }
                            },
				            new {name= "t", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Ton")}
				                   }
				            },
                            new {name= "oz", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Ounce")}
				                   }
				            },
                            new {name= "lb", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Pound")}
				                   }
				            },
                            new {name= "ozt", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Troy Ounces")}
				                   }
				            },
                            new {name= "lbt", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Troy Pounds")}
				                   }
				            },
                            new {name= "j", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Jin(China)")}
				                   }
				            },
                            new {name= "l", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.Global._L("Liang(China)")}
				                   }
				            }
			            }                    
		            }      
                }
            }
        };

        protected override void Create()
        {
            this.Inherited(Arguments.Value);

            this.units = new string[] { "kg", "g", "t", "oz", "lb", "ozt", "lbt", "j", "l" };
            this.baseUnit = "g";

            this.fomular = new object();
            this.fomular["g->g"] = "g";
            this.fomular["g->kg"] = "g/1000";
            this.fomular["kg->g"] = "kg*1000";
            this.fomular["g->t"] = "g/1000000";
            this.fomular["t->g"] = "t*1000000";
            this.fomular["g->oz"] = "g*0.035274";
            this.fomular["oz->g"] = "oz/0.035274";
            this.fomular["g->lb"] = "g*0.0022046";
            this.fomular["lb->g"] = "lb/0.0022046";
            this.fomular["g->ozt"] = "g*0.0321507";
            this.fomular["ozt->g"] = "ozt/0.0321507";
            this.fomular["g->lbt"] = "g*0.0026792";
            this.fomular["lbt->g"] = "lbt/0.0026792";
            this.fomular["g->l"] = "g*0.02";
            this.fomular["l->g"] = "l/0.02";
            this.fomular["g->j"] = "g*0.002";
            this.fomular["j->g"] = "j/0.002";
        }
    }
}
